<?php
require_once 'nrg/ut/app.class.js';
?>

var Nrg_Ut_Suite = new Class({
	
	name: null,
	
	ParentApp: null,
	
	test_cases: [],
	
	//--------------------------------------------------------------------------
	//--------------------------------------------------------------------------
	
	initialize: function(name)
	{
		if ( ! instanceOf(name, String) ) {
			throw 'The name must be a string';
		}
		this.name = name;
	},
	
	//--------------------------------------------------------------------------
	
	addTestCase: function(TestCase)
	{
		if ( ! instanceOf(TestCase, Nrg_Ut_TestCase) ) {
			throw 'The test case must be an instance of Nrg_Ut_TestCase';
		}
		TestCase.setParentSuite(this);
		this.test_cases[this.test_cases.length] = TestCase;
	},
	
	//--------------------------------------------------------------------------
	
	getName: function()
	{
		return this.name;
	},
	
	//--------------------------------------------------------------------------
	
	setParentApp: function(ParentApp)
	{
		if ( ! instanceOf(ParentApp, Nrg_Ut_App) ) {
			throw 'The parameter must be an instance of Nrg_Ut_TestCase';
		}
		this.ParentApp = ParentApp;
	},
	
	//--------------------------------------------------------------------------
	
	getParentApp: function()
	{
		return this.ParentApp;
	},
	
	//--------------------------------------------------------------------------
	
	run: function()
	{
		this.test_cases.each(function(Tc){
			this.getParentApp().logTc(Tc.getName());
			Tc.run();
		}.bind(this));
	}
	
	//--------------------------------------------------------------------------
	
});